package cn.com.smart.module.monitor.noticeLog.controller;

import cn.com.smart.common.utils.poi.ExcelUtil;
import cn.com.smart.framework.aspectj.lang.annotation.Log;
import cn.com.smart.framework.aspectj.lang.enums.BusinessType;
import cn.com.smart.framework.web.controller.BaseController;
import cn.com.smart.framework.web.domain.AjaxResult;
import cn.com.smart.framework.web.page.TableDataInfo;
import cn.com.smart.module.monitor.noticeLog.domain.SysNoticeLog;
import cn.com.smart.module.monitor.noticeLog.service.ISysNoticeLogService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 用户以读信息信息操作处理
 * 
 * @author xman
 * @date 2020-02-18
 */
@Controller
@RequestMapping("/bi/sysNoticeLog")
public class SysNoticeLogController extends BaseController
{
    private String prefix = "bi/sysNoticeLog";
	
	@Autowired
	private ISysNoticeLogService sysNoticeLogService;
	
	@RequiresPermissions("bi:sysNoticeLog:view")
	@GetMapping()
	public String sysNoticeLog()
	{
	    return prefix + "/sysNoticeLog";
	}
	
	/**
	 * 查询用户以读信息列表
	 */
	@RequiresPermissions("bi:sysNoticeLog:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(SysNoticeLog sysNoticeLog)
	{
		startPage();
        List<SysNoticeLog> list = sysNoticeLogService.selectSysNoticeLogList(sysNoticeLog);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出用户以读信息列表
	 */
	@RequiresPermissions("bi:sysNoticeLog:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SysNoticeLog sysNoticeLog)
    {
    	List<SysNoticeLog> list = sysNoticeLogService.selectSysNoticeLogList(sysNoticeLog);
        ExcelUtil<SysNoticeLog> util = new ExcelUtil<SysNoticeLog>(SysNoticeLog.class);
        return util.exportExcel(list, "sysNoticeLog");
    }
	
	/**
	 * 新增用户以读信息
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存用户以读信息
	 */
	@RequiresPermissions("bi:sysNoticeLog:add")
	@Log(title = "用户以读信息", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(SysNoticeLog sysNoticeLog)
	{		
		return toAjax(sysNoticeLogService.insertSysNoticeLog(sysNoticeLog));
	}

	/**
	 * 修改用户以读信息
	 */
	@GetMapping("/edit/{userId}")
	public String edit(@PathVariable("userId") Long userId, ModelMap mmap)
	{
		SysNoticeLog sysNoticeLog = sysNoticeLogService.selectSysNoticeLogById(userId);
		mmap.put("sysNoticeLog", sysNoticeLog);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存用户以读信息
	 */
	@RequiresPermissions("bi:sysNoticeLog:edit")
	@Log(title = "用户以读信息", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(SysNoticeLog sysNoticeLog)
	{		
		return toAjax(sysNoticeLogService.updateSysNoticeLog(sysNoticeLog));
	}
	
	/**
	 * 删除用户以读信息
	 */
	@RequiresPermissions("bi:sysNoticeLog:remove")
	@Log(title = "用户以读信息", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(sysNoticeLogService.deleteSysNoticeLogByIds(ids));
	}
	
}
